﻿using Furion.DependencyInjection;
using FurStudy.Application;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FurStudy.Web.Entry.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class ValueController : ControllerBase
    {
        private readonly IBusinessService<Person> _businessService;
        private readonly IBusinessService<Person> _otherBusinessService;
        private readonly SelfService _selfService;

        public ValueController(Func<string, ITransient, object> resolveNamed)
        {
            // 解析服务
            _businessService = resolveNamed("BusName1", default) as IBusinessService<Person>;
            _otherBusinessService = resolveNamed("BusName2", default) as IBusinessService<Person>;
        }

        [HttpGet]
        public string GetName()
        {
            return _businessService.GetName() + "----------" + _otherBusinessService.GetName();
        }

        public ValueController(SelfService selfService)
        {
            _selfService = selfService;
        }

        [HttpGet]
        public Person Get(int id)
        {
            return _selfService.Get(id);
        }
    }
}
